<template>
  <div>
    <Chart :cdata="cdata" />
  </div>
</template>

<script>
import Chart from './chart.vue'
export default {
  data () {
    return {
      cdata: {
        category: [],
        lineData: [],
        barData: [],
        rateData: [],
        data11:[],
        data1l:[],
        id:[]
      }
    };
  },
  components: {
    Chart,
  },
  mounted () {
    // this.setData();
    this.getDemo();
  },
  methods: {
    getDemo(){
      this.$axios.get("./data.json")
          .then(res=>{
            // console.log(res.data)
            // this.jokes=res.data.jokes
            // console.log(this.jokes)

            // console.log(res.data.jokes)
            this.cdata.category=res.data.id
            this.cdata.lineData=res.data.data11
            this.cdata.barData=res.data.data1l
            // console.log(this.lineData)
          })
      // .catch((err)=>{
      //
      // })
    },
    // 根据自己的业务情况修改
    // setData () {
    //   for (let i = 0; i < this.cdata.barData.length -1; i++) {
    //     let rate = Math.abs(this.cdata.barData[i] - this.cdata.lineData[i])/ this.cdata.lineData[i];//let rate = this.cdata.barData[i] / this.cdata.lineData[i];
    //     // let rate =this.cdata.barData[i];
    //     this.cdata.rateData.push(rate.toFixed(2));
    //   }
    // },
  }
};
</script>

<style lang="scss" scoped>
</style>
